package com.houzehui.mnpromotion.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.houzehui.mnpromotion.entity.Promotion;
import com.houzehui.mnpromotion.service.IPromotionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author houzehui
 * @since 2022-04-08
 */
@RestController
@RequestMapping("/promotion")
public class PromotionController {

    @Autowired
    IPromotionService iPromotionService;


    @GetMapping("getpromotion")
    public String getpromotion(Promotion promotion){
        System.err.println(promotion);
        QueryWrapper<Promotion> wrapper = new QueryWrapper<>();
        wrapper.eq("pid",promotion.getPid());

        Promotion promotion1 = iPromotionService.getBaseMapper().selectOne(wrapper);

        return promotion1.getPname();
    }

    @GetMapping("getpro")
    public List<Promotion> getpro(){
        List<Promotion> list = iPromotionService.list();

        return list;
    }

}
